﻿CREATE TABLE [dbo].[Tariff]
(
	Id int NOT NULL CONSTRAINT PK_Tariff PRIMARY KEY IDENTITY (1,1), 
	Segment int NOT NULL CONSTRAINT FK_Tariff_Segment REFERENCES Segment(Id),
	ClassType int NOT NULL CONSTRAINT FK_Tariff_ClassType REFERENCES ClassType(Id),
	Operator varchar(10) NOT NULL CONSTRAINT FK_Tariff_Operator REFERENCES Operator(Code),
	PassengerType int NOT NULL CONSTRAINT FK_Tariff_PassengerType REFERENCES PassengerType(Id),
	BasePrice MONEY NOT NULL CONSTRAINT CK_Tariff_BasePrice CHECK (BasePrice > 0),
	StartDate DateTime NOT NULL,
	EndDate DateTime NOT NULL CONSTRAINT CK_Tariff_EffectiveDate CHECK (EndDate > StartDate)
)